function hexToDecimal(hex) {
  const hexChars = '0123456789ABCDEF';
  let decimal = 0;
  const len = hex.length;
  for (let i=0; i < len; i++) {
    decimal += hexChars.indexOf(hex[i]) * 16**(len-i-1);
  }
  return decimal;
}


let output = hexToDecimal("A");
console.log(output);